#!/bin/bash

rm main.jar &> /dev/null
rm -rf log/ &> /dev/null
mkdir log &> /dev/null

echo \> Compilando programa e gerando jar
ant &> log/compile.log

echo \> Executando testes com codigo correto
for i in $( ls -l tests | grep ^- | awk '{print $8}' ); do
#	head -n 1 tests/$i &>> log/tests0.log
	java -jar main.jar tests/$i &>> log/tests0.log
	echo &>> log/tests0.log
done

echo \> Executando testes da pasta 1
for i in $( ls -l tests/semant/1 | grep ^- | awk '{print $8}' ); do
	head -n 1 tests/semant/1/$i &>> log/tests1.log
	java -jar main.jar tests/semant/1/$i &>> log/tests1.log
	echo &>> log/tests1.log
done

echo \> Executando testes da pasta 2
for i in $( ls -l tests/semant/2 | grep ^- | awk '{print $8}' ); do
	head -n 1 tests/semant/2/$i &>> log/tests2.log
	java -jar main.jar tests/semant/2/$i &>> log/tests2.log
	echo &>> log/tests2.log
done

echo \> Executando testes da pasta 3
for i in $( ls -l tests/semant/3 | grep ^- | awk '{print $8}' ); do
	head -n 1 tests/semant/3/$i &>> log/tests3.log
	java -jar main.jar tests/semant/3/$i &>> log/tests3.log
	echo &>> log/tests3.log
done

less log/tests0.log
less log/tests1.log
less log/tests2.log
less log/tests3.log


